//<![CDATA[
function stripHtmlTags(s,max){return s.replace(/&lt;.*?&gt;/ig, '').split(/\s+/).slice(0,max-1).join(' ')}

function getSummaryLikeWP(id) {
return document.getElementById(id).innerHTML.split(/&lt;!--\s*more\s*--&gt;/)[0];
}

function getSummaryImproved(post,max){
var re = /&lt;.*?&gt;/gi
var re2 = /&lt;br.*?&gt;/gi
var re3 = /(&lt;\/{1}p&gt;)|(&lt;\/{1}div&gt;)/gi
var re4 = /(&lt;style.*?\/{1}style&gt;)|(&lt;script.*?\/{1}script&gt;)|(&lt;table.*?\/{1}table&gt;)|(&lt;form.*?\/{1}form&gt;)|()|()/gi

post = post.replace(re4,'')
post = post.replace(re3,'&lt;br /&gt; ').split(re2)

for(var i=0; i&lt;post.length; i++){
post[i] = post[i].replace(re,'');
}
var post2 = new Array();
for(var i in post) {
//if(post[i]!='' &amp;&amp; post[i]!=' ' &amp;&amp; post[i] != '\n') post2.push(post[i]);
if(/[a-zA-Z0-9]/.test(post[i])) post2.push(post[i]) ;

}


var s = "";
var indentBlank = "";
for(var i=0;i&lt;indent;i++){
indentBlank += " ";
}
if(post2.join('&lt;br/&gt;').split(' ').length &lt; max-1 ){
s = post2.join(indentBlank +' &lt;br/&gt;');
} else {
var i = 0;
while(s.split(' ').length &lt; max){
s += indentBlank + ' ' + post2[i]+'&lt;br/&gt;';
i++;
}
}
return s;
}


function createSummaryAndThumb(pID){
var div = document.getElementById(pID);
var content = div.innerHTML;
if (/&lt;!--\s*more\s*--&gt;/.test(content)) {
div.innerHTML = getSummaryLikeWP(pID);
div.style.display = "block";
}
else {

var imgtag = "";
var img = div.getElementsByTagName("img");
var summ = summary_noimg;
if(img.length&gt;=1) {
if(thumbnail_mode == "float") {
imgtag = '&lt;span style="float:left; padding:0px 10px 5px 0px;"&gt;&lt;img src="'+img[0].src+'" width="'+img_thumb_width+'px" height="'+img_thumb_height+'px"/&gt;&lt;/span&gt;';
summ = summary_img;
} else {
imgtag = '&lt;div style="padding:5px" align="center"&gt;&lt;img style="max-width:'+img_thumb_width+'px; max-height:'+img_thumb_height+'px;" src="'+img[0].src+'" /&gt;&lt;/div&gt;';
summ = summary_img;
}
}

var summary = (classicMode) ? imgtag + '&lt;div&gt;' + stripHtmlTags(content,summ) + '&lt;/div&gt;' : imgtag + '&lt;div&gt;' + getSummaryImproved(content,summ) + '&lt;/div&gt;';

div.innerHTML = summary;
div.style.display = "block";
}
}
//]]>